import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:provider/provider.dart';
import '../core/theme_config.dart';
import 'package:package_info_plus/package_info_plus.dart';

class AboutPage extends StatelessWidget {
  const AboutPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final themeConfig = Provider.of<ThemeConfig>(context);
    
    return Scaffold(
      appBar: AppBar(
        title: Text('关于'),
        toolbarHeight: 32,
        centerTitle:  false,
        backgroundColor: themeConfig.currentGradient.colors.first,
        automaticallyImplyLeading: false,
        //字体颜色
        titleTextStyle: TextStyle(fontSize: 18,color: themeConfig.currentTextColor),
      ),
      body: Container(
        decoration: BoxDecoration(
          gradient: themeConfig.currentGradient,
        ),
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                'stars_moon',
                style: TextStyle(
                  fontSize: 24,
                  fontWeight: FontWeight.bold,
                  color: themeConfig.currentTextColor,
                ),
              ),
              SizedBox(height: 8),
              FutureBuilder<PackageInfo>(
                future: PackageInfo.fromPlatform(),
                builder: (context, snapshot) {
                  if (snapshot.connectionState == ConnectionState.done) {
                    return Text(
                      '版本：${snapshot.data?.version ?? 'N/A'}',
                      style: TextStyle(
                        fontSize: 16,
                        color: themeConfig.currentTextColor.withOpacity(0.8),
                      ),
                    );
                  } else {
                    return Text(
                      '版本：N/A',
                      style: TextStyle(
                        fontSize: 16,
                        color: themeConfig.currentTextColor.withOpacity(0.8),
                      ),
                    );
                  }
                },
              ),
              SizedBox(height: 8),
              Text(
                '声明：本软件仅供学习使用，请勿用于商业用途，数据源均来自网络，不保证数据的准确性和完整性。',
                style: TextStyle(
                  fontSize: 16,
                  color: themeConfig.currentTextColor.withOpacity(0.8),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
